import DefineOptions from 'unplugin-vue-define-options/vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'

const pathResolve = dir => {
  return resolve(__dirname, '.', dir)
}

const alias = {
  '@': pathResolve('src')
}

// const extensions = ['.js', '.vue', '.json'] 省略引入的index.vue 或index.js文件 不建议配置

// https://vitejs.dev/config/
export default ({ command }) => {
  return {
    base: './',
    resolve: {
      alias
      // extensions
    },
    server: {
      port: 3002,
      host: '0.0.0.0',
      open: false,
      proxy: {
        // 代理配置
        // '/dev':
        //   'https://www.fastmock.site/mock/48cab8545e64d93ff9ba66a87ad04f6b/'
      }
    },
    build: {
      rollupOptions: {
        output: {
          manualChunks: {}
        }
      }
    },
    plugins: [vue(), DefineOptions()]
  }
}
